Rust Essentials by Balbaert Ivo

Rust Essentials by Balbaert Ivo

Author:Balbaert, Ivo [Balbaert, Ivo]
Language: eng
Format: azw3, epub, pdf
Publisher: Packt Publishing
Published: 2015-05-26T16:00:00+00:00


It again shows Rust's commitment to be on the safe side; if it's Ok, it will give back a value of the T type, if there is a problem, then it will give back the error that will be a value of the E type (which is usually an error message string). So, we could read them also as Ok(what) and Err(why), where what has the T type and why has the E type.

So, why are Option and Result killer features of Rust? Remember from Chapter 4, Structuring Data and Matching Patterns in the section Result and Option how we used Option when getting a number input? Here, it is given again:

let input_num: Result<u32, _> = buf.trim().parse();



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.